#include <cstdio>
#include <cstring>
int a[1000] = {0};
int f[1000] = {0};

int isJump(int a[], int n)
{
	for ( int i = 0; i < n - 1; i++ )
	{
		int d = a[i] - a[i+1];
		if ( d < 0 ) {
			d = -d;
		}
		if ( d >= 1 && d <= n - 1 ) {
			f[d] = 1;
		}
	}
	
	int ret = 1;
	for ( int i = 1; i < n; i++ ) {
		if ( f[i] == 0 ) {
			ret = 0;
			break;
		}
	}
	return ret;
}

int main()
{
	freopen("jump.in", "r", stdin);
	freopen("jump.out", "w", stdout);
	int m = 0, n = 0;
	scanf("%d %d", &m, &n);
	
	for ( int i = 0; i < m; i++ ) 
	{
		memset(&a[0], 0, sizeof(a));
		memset(&f[0], 0, sizeof(f));
		for ( int i = 0; i < n; i++ )
		{
			scanf("%d", &a[i]);	
		}
		if ( isJump(a, n) )
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
